import requests

# 6、超时设置

def getHtml(url):

    try:
        res = requests.get(url,timeout=0.5)
        print(res.status_code)
        res.raise_for_status()
        print(res.text)
    except:
        print("get http error!")

if __name__=="__main__":
    url = "https://www.baidu.com"
    getHtml(url)
